package main

import (
	"html/template"
	"net/http"
)

func sayHello(w http.ResponseWriter, r *http.Request) {
	//解析模版
	t, err := template.ParseFiles("./index.tmpl")
	if err != nil {
		panic(err)
	}
	//渲染模版
	name := "张三"
	err = t.Execute(w, name)
	if err != nil {
		panic(err)
	}
}

func main() {
	http.HandleFunc("/", sayHello)
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic(err)
	}
}
